package org.pentaho.di.ui.core.dialog;

import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.ui.core.FormDataBuilder;

public class BaseMessageDialog extends BaseDialog {
    private static Class<?> PKG = BaseMessageDialog.class;
    private String message;

    public BaseMessageDialog(Shell shell, String title, String message) {
        this(shell, title, message, BaseMessages.getString(PKG, "System.Button.OK", new String[0]), -1);
    }

    public BaseMessageDialog(Shell shell, String title, String message, int width) {
        this(shell, title, message, BaseMessages.getString(PKG, "System.Button.OK", new String[0]), width);
    }

    public BaseMessageDialog(Shell shell, String title, String message, String buttonLabel, int width) {
        super(shell, title, width);
        this.message = message;
        this.buttons.put(buttonLabel, (event) -> {
            this.dispose();
        });
    }

    protected Control buildBody() {
        Label message = new Label(this.shell, 16448);
        message.setText(this.message);
        this.props.setLook(message);
        message.setLayoutData((new FormDataBuilder()).top().left().right(100, 0).result());
        return message;
    }
}

